<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
	 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">
        <meta name="description" content="Violate Responsive Admin Template">
        <meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
        <link href="<%=path %>/assets2/js/sweetalert/sweetalert.css" rel="stylesheet">
   		<script src="<%=path %>/assets2/js/sweetalert/sweetalert-dev.js"></script>
   		<script src="<%=path %>/assets2/js/sweetalert/sweetalert.min.js"></script> 
    </head>
    
		<div class="row">
			<div class="col-md-6 form-group">
				<label>登录名称</label> <input type="text"
					class="input-sm form-control" name="loginName" placeholder="请输入正确的手机号码" id="loginName">
			</div>
			<div class="col-md-6 form-group">
				<label>角色类别</label>
				<select name="userType" id="userType9"
					class="form-control input-sm">
					<option value="">请选择</option>
					<option value="7">论坛管理员</option>
<!-- 					<option value="8">小记者管理</option> -->
<!-- 					<option value="9">社团管理员</option> -->
				</select>
			</div>
		</div>
		<div class="row">
			<div class="form-group">
				<button class="btn btn-sm btn-primary col-md-4 col-md-offset-4" type="button" onclick="addBtn()">添加</button>
			</div>
		</div>

	<script type="text/javascript">
		//添加人员信息
		function addBtn(){
			var loginName = $("#loginName").val();
			var userType = $("#userType9").val();
			if(loginName==null||loginName==""){
				swal({ 
		   			  title: "提交失败", 
		   			  text: "请输入手机号码", 
		   			  type: "warning",
		   			});
				return false;
			}else if(loginName.match(/(^1[3|4|5|6|7|8|9][0-9]\d{8}$)/)==null){
				swal({ 
		   			  title: "提交失败", 
		   			  text: "请输入正确的手机号码", 
		   			  type: "warning",
		   			});
				return false;
			}else if(userType==null||userType==""){
				swal({ 
		   			  title: "提交失败", 
		   			  text: "请选择角色类别", 
		   			  type: "warning",
		   			});
				return false;
			}else{
				$.ajax({
					 type:"POST",
			         url: "<%=path %>/liveManager/addUserInfo",
			         data: {"loginName":loginName,"userType":userType},
			         dataType: 'json',
			         success: function(data,status,xhr){
			        	 if(data.num==1){
			        		 swal({ 
					   			  title: "提交成功", 
					   			  text: data.msg, 
					   			  type: "success",
					   			},function(){
					   			 	$("#tabId").bootstrapTable('refresh');
					   			 	$('#myModal').modal('hide')
					   			});
			        	 }else{
			        		 swal({ 
					   			  title: "提交失败", 
					   			  text: data.msg, 
					   			  type: "error",
					   			}); 
			        	 }
			         },error:function (){
			        	 swal({ 
				   			  title: "提交失败", 
				   			  text: "网络错误,请稍后尝试~", 
				   			  type: "error",
				   			});
			         }
				});
			}
		};
	</script>
</html>